package com.example.demotest;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class GetImageUtil {
	public static Bitmap getBitmap(String url) {
		InputStream is = null;
		try {
			URL path = new URL(url);
			if (path!=null) {
				HttpURLConnection hc = (HttpURLConnection) path.openConnection();
				hc.setConnectTimeout(3000);
				hc.setRequestMethod("GET");
				hc.setRequestProperty("User-Agent",
						"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
				hc.setDoInput(true);
				int responseCode = hc.getResponseCode();
				if (responseCode == 200) {
					is = hc.getInputStream();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return  BitmapFactory.decodeStream(is);
	}

}
